package net.love5z.web.service;

import java.util.ArrayList;
import java.util.List;

import net.love5z.web.common.utils.ObjectPropUtils;
import net.love5z.web.dao.UserPacRuleMapper;
import net.love5z.web.dao.dto.UserPacRuleDto;
import net.love5z.web.service.bo.UserPacRuleBo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserPacRuleService {

    @Autowired
    private UserPacRuleMapper userPacRuleMapper;

    public List<UserPacRuleBo> getUserPacRuleListByUserId(long userId) {
        List<UserPacRuleDto> _list = userPacRuleMapper.getPacRuleListByUserId(userId);
        List<UserPacRuleBo> list = new ArrayList<UserPacRuleBo>();
        ObjectPropUtils.copyCollectionProperties(_list, list, UserPacRuleBo.class);

        return list;
    }

    public int addUserPacRuleByUserId(String rule, long userId) {
        return userPacRuleMapper.insertRuleByUserId(rule, userId);
    }
}
